	var app = angular.module('app', []);
	
	// 控制器
	app.controller('demoCtrl', ['$scope', '$http', function($scope, $http){
		  selectCtrl($scope, $http);
		  formCtrl($scope, $http);
	}]);
	
	function selectCtrl($scope, $http) {
		 var url = keter.path+'/public/codelist/'+'dept';		
		 $http.get(url).success(function(data) {
			$scope.c_dept = data;
			console.log(data[0].value);
			//选项默认值
		    $scope.formData.dept = data[0].value;
	     })	
	}
	
		function formCtrl($scope, $http) {
			// $scope will allow this to pass between controller and view
			$scope.formData = {};
//			$scope.create_date="";
			// process the form
			$scope.processForm = function() {
				console.log(Date.parse($scope.create_date));
				$http({
			        method  : 'POST',
			        url     : keter.reqRoot+'/add',
			        data    : $.param($scope.formData),  // pass in data as strings
			        // set the headers so angular passing info as form data (not request payload)
			        headers : { 'Content-Type': 'application/x-www-form-urlencoded' }  
			    })
			        .success(function(data) {
			        	 if (data.success) {
				                $scope.message = "操作成功！";
				                $scope.errorMessage = "";
				            } else {
				            	$scope.errorMessage = data.message;
				            	 $scope.message = "";
				            }
			        });
			};
		}
